const express = require('express')
import {Fail, Ok} from '../utils/commonResponse'
import asyncQuery from '../utils/asyncQuery'
const router = express.Router()

interface IUser {
    id: number
    name: string
    password: string
    money: number
}

router.get('/info', async (req: any, res: any) => {
    try {
        const result: IUser = await asyncQuery(`SELECT * FROM admin`)
        console.log('process.env.NODE_BASE_MYSQL_URL', process.env.NODE_BASE_MYSQL_URL)
        Ok<IUser>(res, result)
    } catch (e) {
        Fail(res, e)
    }
})

router.post('/info', async (req: any, res: any) => {
    const result: IUser = await asyncQuery(`SELECT * FROM admin`)
    Ok<IUser>(res, result)
})

export default router